<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>添加账户余额</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <!-- 当前页面样式 -->
    <link rel="stylesheet" href="<s:url value="/css/common.css"/>"/>
    <!-- 当前页面样式 END -->
    <script type="text/javascript" src="<c:url value="/js/jquery-1.3.2.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
	<script type="text/javascript" src="<s:url value="/js/jquery.validate.min.js" />"></script>
	<script type="text/javascript" src="<s:url value="/js/pwms.validate.js?v13" />"></script>
	<script type="text/javascript" src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		var flag="${request.target}";
		if(flag=="update"){
			$("#acctBal").attr("action","<%=basePath%>/accountBalance/updateAcctBalance.ct");
		}
		//验证金额
		jQuery.validator.addMethod("isMoney", function(value,element) {
			var reg= /^([1-9][\d]{0,9}|0)(\.[\d]{1,2})?$/;
			if(value==0){
				return this.optional(element) || false;
			}
			if(reg.test(value)){
				if(flag=="update"){
					var symbol_ =$("#symbol").val();
					var origin=$("#origin").val();
					if(symbol_=="-"){
						var last=parseInt(parseFloat(value)*100*(-1))+parseInt(parseFloat(origin)*100);
						if(last<0){
							var msg="减少金额不能大于原始金额";
							alert(msg);
							return this.optional(element) || false;
						}
					}
				}
				return this.optional(element) || true;
			}			
			return this.optional(element) || false;
			},"必须在0-9999999999.99之间，最多2位小数");
		
		$("#acctBal").validate({
			debug : true,
			submitHandler : function(form) {
				$("#btnAdd").attr("disabled",true);
					form.submit();
			},
			rules : {
				"accountBalance.currentDate":{required : true},
				"accountBalance.account":{required : true},
				"accountBalance.orgCode":{required : true},
				"accountBalance.amt" : {required : true,isMoney:true},
				"accountBalance.status":{required : true}
			},
			messages : {
			"accountBalance.currentDate":{required : "必填"},
			"accountBalance.account":{required : "必填"},
			"accountBalance.orgCode":{required : "必选"},
			"accountBalance.amt" : {required :"必填"},
			"accountBalance.status":{required : "必选"}
			},errorPlacement: function(error, element) { 
			    if ( element.is(":radio") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is(":checkbox") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is("input") ) {
			    	error.appendTo ( element.parent().next() ); 
			    }
			    else 
			    	error.appendTo ( element.parent().next()); 
			} 
		});
	});
	</script>
</head>
<body>
	<s:form id="acctBal" action="/accountBalance/addAcctBalance.ct" method="post"  theme="simple"  >
				<table width="100%" class="tb" >
			        <tr class="tb-line">
			            <td class="tb-td" colspan="6">
				            <div class="tb-h2">POS收单运营管理平台</div>
					   	</td>
			        </tr>
	                <tr class="tb-line bg-gray">
			            <td class="tb-td" colspan="4">
			            		<div class="tb-h3">
			                	<s:if test="#request.target==\"update\"">
			                		修改账户余额
			                	</s:if>
			                	<s:else>
			                		添加账户余额
			                	</s:else>
			                	</div></td>
			        </tr>
					<tr class="tb-line">						     
				    	<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title">日期：</div>
			            </td>
			            <td class="tb-td" >				            		
			            		<s:if test="#request.target==\"update\"">
			            			<label class="tb-input-mini">
			                		<s:textfield name="accountBalance.currentDate"
									cssClass="queryWidth" disabled="true"></s:textfield>
									<s:hidden name="accountBalance.currentDate"></s:hidden>
									</label>
			                	</s:if>		             								
			                	<s:else>
			                	 <label class="tb-input-mini">
                				<s:textfield name="accountBalance.currentDate" placeholder="必填" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});" cssClass="queryWidth"></s:textfield>
               	 				</label>
               	 				<font color="red">*</font>
			                	</s:else>		
						</td>
						<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title">机构名称：</div>
			            </td>
			            <td class="tb-td" >
                			<s:if test="#request.target==\"update\"">
                			<label class="tb-select">
				 			<s:select name="accountBalance.orgCode" list="orgList" listKey="InsIdCd" listValue="InsName"  cssClass="queryWidth"/> 
                			</label>
                			</s:if>
                			<s:else>
                				<label class="tb-select">
				 					<s:select name="accountBalance.orgCode" list="orgList" listKey="InsIdCd" listValue="InsName"  cssClass="queryWidth"/> 
                				</label>
                				<font color="red">*</font>
                			</s:else>
						</td>
						</tr>
						<tr class="tb-line">					
				    	<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title">账号：</div>
			            </td>
			            <td class="tb-td" >             									
							<label class="tb-input-lengthen">
							*		             	
							</label>
							<s:hidden name="accountBalance.account" value="*"></s:hidden>
						</td>
						<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title">账户余额（元）：</div>
			            </td>
			            <td class="tb-td" >		            		
			            		<s:if test="#request.target==\"update\"">
			            		<label class="tb-input-lengthen">
				 				<s:property value="accountBalance.changeValue"/><font color="red">(当前)</font>
				 				<s:hidden name="accountBalance.changeValue" id="origin"></s:hidden>
				 				</label>
                				</s:if>
                				<s:else>
                				<label class="tb-input-lengthen">            				
			             		<s:textfield maxLength="200" placeholder="必须在0-9999999999.99之间，最多2位小数" name="accountBalance.amt" cssClass="queryWidth"></s:textfield>								
                				</label>
                				<font color="red">*</font>	
                				</s:else>						
						</td>
						</tr>					
					<tr class="tb-line">
			        <td align="right" class="tb-td" style="width:110px;">
                	<div class="tb-h4" id="title">状态：</div>
            		</td>
					<td class="tb-td">
					<s:if test="#request.target==\"update\"">
                	<label>
                		<s:radio name="accountBalance.status" list="#{'01':'冻结','00':'正常'}"  cssClass="queryWidth" /> 
					</label>
					</s:if>
					<s:else>
						<label>
							正常
						</label>
					</s:else>
					</td>
					<s:if test="#request.target==\"update\"">
					<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title">修改余额（元）：</div>
			            </td>
			            <td class="tb-td" >
				 				<s:select name="accountBalance.symbol" list="#{'+':'增加','-':'减少'}"  id="symbol" cssClass="queryWidth"/> 
                				<label class="tb-input-lengthen">								
			             		<s:textfield maxLength="200" id="cv" placeholder="必须在0-9999999999.99之间，最多2位小数" name="accountBalance.amt" cssClass="queryWidth"></s:textfield>								
                				</label>
                				<font color="red">*</font>	
				 				</label>
						</td>
					</s:if>
					<s:else>
						<td align="right" class="tb-td" colspan="2">
				        	
			            </td>
					</s:else>           								
					</tr>
					   					
				</table>		
		      <table width="100%" border="0" cellspacing="0" class="table">
		           	<tr class="tb-line">
						<td colspan="4" align="center"><span style="color: red"><s:actionerror /></span>
							<span style="color: red;"><s:actionmessage /></span > <span style="color: red;"><s:fielderror
									cssClass="fieldError" /></span>
							<span id="otherError"></span>
						</td>
					</tr>
					<tr class="tb-line">
			            <td class="tb-td line-submit" align="center" colspan="4">
			                <label class="tb-input-submit">		                
			                	<s:submit id="btnAdd" value="保  存" />								
							</label>
			                <label class="tb-input-submit">
								<input type="reset" value="取  消"/>
							</label>
							<label class="tb-input-submit">
								<input type="button" value="返回" onclick="history.back()"/>
							</label>
						</td>
					</tr>
            </table>
			</s:form>
</body>
</html>